package com.cee.service.Impl;

import com.cee.dao.OneTypeMapper;
import com.cee.model.OneType;
import com.cee.service.OneTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
@Transactional
public class OneTypeServiceImpl implements OneTypeService {

    @Autowired
    private OneTypeMapper oneTypeMapper;

    @Override
    public List<OneType> getOneTypeList() {
        return oneTypeMapper.getOneTypeList();
    }

    @Override
    public void deleteOneType(Integer id) {

        OneType oneType = new OneType();
        oneType.setId(id);
        oneType.setDelDateTime(new Date());

        log.info("逻辑删除OneType, id={}", id);
        oneTypeMapper.updateById(oneType);
    }

    @Override
    public void saveOneType(OneType oneType) {

        log.info("添加OneType, OneType={}", oneType);
        oneTypeMapper.insert(oneType);
    }

    @Override
    public OneType getOneTypeByName(String oneTypeName) {
        return oneTypeMapper.getOneTypeByName(oneTypeName);
    }
}
